//
//  ZHFCollectionReusableView.m
//  GoTraveling
//
//  Created by dllo on 15/12/23.
//  Copyright © 2015年 开发华佗. All rights reserved.
//

#import "ZHFCollectionReusableView.h"

@interface ZHFCollectionReusableView ()

@property (nonatomic,strong) UIImageView *imageView;

@property (nonatomic,strong) UILabel *titleLabel;

@property (nonatomic,strong) UIButton *allButton;

@end

@implementation ZHFCollectionReusableView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    
    if (self) {
        
        self.backgroundColor = [UIColor colorWithRed:0.98 green:0.96 blue:0.91 alpha:1.0];
        
        [self creatSubViews];
    }
    
    return self;
}

- (void)creatSubViews
{
    //每个section头部左边的小图片
    self.imageView = [[UIImageView alloc] initWithFrame:CGRectMake(10 * ADAPT_WIDTH, 0, 8 * ADAPT_WIDTH, 25 * ADAPT_HEIGHT)];
    self.imageView.center = CGPointMake(self.imageView.center.x, self.frame.size.height / 2 + 5 * ADAPT_WIDTH);
    self.imageView.layer.cornerRadius = 4;
    self.imageView.layer.masksToBounds = YES;
    self.imageView.image = [UIImage imageNamed:@"login_btn"];
    [self addSubview:self.imageView];
    
    //每个section头部的标题label
    self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.imageView.frame.origin.x + self.imageView.frame.size.width + 10 * ADAPT_WIDTH, self.imageView.frame.origin.y, SCREEN_WIDTH - 30 * ADAPT_WIDTH, self.imageView.frame.size.height)];
    self.titleLabel.font = [UIFont systemFontOfSize:20 weight:0.1];
//    self.titleLabel.backgroundColor = [UIColor greenColor];
    self.titleLabel.textColor = [UIColor colorWithRed:0.29 green:0.29 blue:0.3 alpha:1.0];
    [self addSubview:self.titleLabel];
    
    //每个section头部右边的小箭头按钮
    self.allButton = [UIButton buttonWithType:UIButtonTypeCustom];
    self.allButton.frame = CGRectMake(SCREEN_WIDTH - 30 * ADAPT_WIDTH, 0, 20 * ADAPT_WIDTH, 20 * ADAPT_WIDTH);
//    self.allButton.backgroundColor = [UIColor purpleColor];
    self.allButton.center = CGPointMake(self.allButton.center.x, self.frame.size.height / 2 + 5 * ADAPT_WIDTH);
    [self.allButton setBackgroundImage:[UIImage imageNamed:@"trip_waypoint_disclosure_indicator"] forState:UIControlStateNormal];
    [self.allButton addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:self.allButton];
}

- (void)createAllView:(BOOL)ishiden {
    
    if (ishiden) {
        self.allButton.hidden = YES;
    }
    else {
        
        self.allButton.hidden = NO;
    }
}

- (void)buttonAction:(UIButton *)button
{
    //
    [self.delegate pushAllViewController:self.num];
}

//重写属性的set方法  进行赋值
- (void)setTitleText:(NSString *)titleText
{
//    NSLog(@"hahaha");
    
    self.titleLabel.text = titleText;
}

@end
